package com.atguigu.yygh.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.atguigu.yygh.cmn.mapper.DictMapper;
import com.atguigu.yygh.model.cmn.Dict;
import com.atguigu.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author wans
 * @create 2021-11-17 10:04
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {
    private DictMapper mapper;
    public DictListener(DictMapper mapper) {
        this.mapper=mapper;
    }

    //轮到每一行数据就调用一次
    @Override
    public void invoke(DictEeVo vo, AnalysisContext analysisContext) {
        Dict po = new Dict();
        BeanUtils.copyProperties(vo,po);
        mapper.insert(po);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
